package com.itheima.goods.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description 批量注册mp插件
 * @Created by itheima
 */
@Configuration
public class MPPluginsRegisterConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //构建批量注册插件的对象
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //mp内置的分页对象
//        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor();
        //自定义的分页对象（实现超页后输出最后一页）
        PaginationInnerInterceptor innerInterceptor = new MyPaginationInnerInterceptor();
        //设置分页大小受限
        innerInterceptor.setMaxLimit(-1l);
        //设置操纵的数据库类型
        innerInterceptor.setDbType(DbType.MYSQL);
        // 设置请求的页面大于最大页后操作， true调回到首页，false 继续请求  默认false
        innerInterceptor.setOverflow(true);
        //注册分页插件
        interceptor.addInnerInterceptor(innerInterceptor);
        return interceptor;
    }


}
